<?	
	class LineDictionaryController extends Controller
	{	
		private function query($dicName)
		{
			return new Query('dic_' . $dicName);
		}
		
		public function load()
		{			
			$query = $this->query($_GET['dic'])
					->take($_GET['start'])
					->limit($_GET['limit']);
			
			$this->jsonp(array(
                'data' => $query->results(),
                'total' => $query->count()
            ));
		}
		
		public function create($dicName)
		{
			$id = $this->query($dicName)->insert();
			$query = $this->query($dicName);
			$where = array('eq' =>  array('id', $id));
			$data = $query->where($where)->result();

            return array(
                'success' => true,
                'data' => $data
            );
		}		

        public function remove($id, $dicName)
        {
			$query = $this->query($dicName);
			$where = array('eq' => array('id', $id));
			
			$query->where($where)->remove();

            return array('success' => true);
        }
		
		public function update($id, $data, $dicName)
		{
			$query = $this->query($dicName);
			$where = array('eq' => array('id', $id));
			
			$query->where($where)->update($data);

            return array('success' => true, 'data' => $data);
		}
	}
?>